package com.hzlj.position.config.service.impl;

import com.fz.common.dict.annotation.DictConvert;
import com.hzlj.position.config.common.dto.operatorActivationLogs.OperatorActivationLogsAddDTO;
import com.hzlj.position.config.common.dto.operatorActivationLogs.OperatorActivationLogsQueryParamDTO;
import com.hzlj.position.config.common.dto.operatorActivationLogs.OperatorActivationLogsQueryResultDTO;
import com.hzlj.position.config.common.model.OperatorActivationLogs;
import com.hzlj.position.config.converter.OperatorActivationLogsConverter;
import com.hzlj.position.config.dao.OperatorActivationLogsDao;
import com.hzlj.position.config.service.OperatorActivationLogsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

import static com.hzlj.position.config.config.IdConfig.POSITION_ID_GEN;

/**
 * 定位-运营商开通-日志(OperatorActivationLogs)表服务接口
 *
 * @author lifh
 * @date 2023-08-17 18:16:57
 */
@Slf4j
@Service
public class OperatorActivationLogsServiceImpl implements OperatorActivationLogsService {
    @Resource
    private OperatorActivationLogsDao operatorActivationLogsDao;

    /**
     * 新增数据
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public OperatorActivationLogsQueryResultDTO saveOperatorActivationLogs(OperatorActivationLogsAddDTO dto) {
        OperatorActivationLogs operatorActivationLogs = OperatorActivationLogsConverter.from(dto);
        operatorActivationLogs.setId(POSITION_ID_GEN.nextIdStr());
        this.operatorActivationLogsDao.save(operatorActivationLogs);
        log.info("【新增数据成功】:operatorActivationLogs={}", operatorActivationLogs);
        return OperatorActivationLogsConverter.from(operatorActivationLogs);
    }

    /**
     * 查询列表：不分页
     */
    @Override
    @DictConvert
    public List<OperatorActivationLogsQueryResultDTO> listOperatorActivationLogs(OperatorActivationLogsQueryParamDTO dto) {
        return this.operatorActivationLogsDao.listOperatorActivationLogs(dto);
    }
}
